package com.cefa.edu.datasource;

/**
 * Created by qimwang on 7/26/17.
 */
public class DynamicDataSourceHolder {

    private static ThreadLocal<String> holder   = new ThreadLocal<>();
    public static String CEFAEDU_DATA_SOURCE = "cefaedu";

    public static String getDataSource() {
        String db = holder.get();
        if (db == null || db.equalsIgnoreCase(CEFAEDU_DATA_SOURCE)) {
            db = CEFAEDU_DATA_SOURCE;
        }
        return db;
    }

    /**
     * 设置当前线程的dataSource
     */
    public static void setDataSource(String str) {
        holder.set(str);
    }

    /**
     * 清理当前线程的dataSource
     */
    public static void clearDataSource() {
        holder.remove();
    }


}